/* $Id: ClientDomainObjectManagerImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.domain.manager.provider;

import java.util.Collection;
import java.util.List;

import ae.pcfc.etks.online.common.dao.ClientDAO;
import ae.pcfc.etks.online.common.dao.ClientRoleReqDAO;
import ae.pcfc.etks.online.common.dao.ClientServiceRoleDAO;
import ae.pcfc.etks.online.common.domain.Client;
import ae.pcfc.etks.online.common.domain.ClientRoleReq;
import ae.pcfc.etks.online.common.domain.ClientServiceRole;
import ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager;
import ae.pcfc.etks.online.common.exception.LookupException;
import ae.pcfc.etks.online.common.exception.PersistenceException;
import ae.pcfc.etks.online.common.vo.TrakheesIdVO;

public class ClientDomainObjectManagerImpl implements ClientDomainObjectManager {

	private ClientDAO clientDAO;
	private ClientRoleReqDAO clientRoleReqDAO;
	private ClientServiceRoleDAO clientServiceRoleDAO;

	/**
	 * setClientDAO
	 * 
	 * @param clientDAO
	 * void
	 */
	public void setClientDAO(ClientDAO clientDAO) {
		this.clientDAO = clientDAO;
	}

	/**
	 * setClientRoleReqDAO
	 * 
	 * @param clientRoleReqDAO
	 * void
	 */
	public void setClientRoleReqDAO(ClientRoleReqDAO clientRoleReqDAO) {
		this.clientRoleReqDAO = clientRoleReqDAO;
	}

	/**
	 * setClientServiceRoleDAO
	 * 
	 * @param clientServiceRoleDAO
	 * void
	 */
	public void setClientServiceRoleDAO(ClientServiceRoleDAO clientServiceRoleDAO) {
		this.clientServiceRoleDAO = clientServiceRoleDAO;
	}

	/**
	 * add
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#add(java.lang.Object)
	 * 
	 */
	public <T> void add(T obj) throws PersistenceException {
		this.clientDAO.add((Client) obj);
	}

	/**
	 * update
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#update(java.lang.Object)
	 * 
	 */
	public <T> void update(T obj) throws PersistenceException {
		this.clientDAO.update((Client) obj);
	}

	/**
	 * delete
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#delete(java.lang.Object)
	 * 
	 */
	public <T> void delete(T obj) throws PersistenceException {
		// TODO Auto-generated method stub

	}

	/**
	 * findByPrimaryKey
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#findByPrimaryKey(java.lang.String)
	 * 
	 */
	@SuppressWarnings("unchecked")
	public <T> T findByPrimaryKey(String id) throws LookupException {
		return (T) this.clientDAO.findByPrimaryKey(Long.parseLong(id));
	}

	/**
	 * findAll
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.BaseDomainObjectManager#findAll()
	 * 
	 */
	public <T> Collection<T> findAll() throws LookupException {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * public String add(Client Client) { return companyDAO.add(Client);
	 * 
	 * }
	 * 
	 * public Client getClientByApplicationId(Long applicationId){ return
	 * companyDAO.getClientByApplicationId(applicationId); }
	 * 
	 * public boolean add(Client client) { return companyDAO.add(client); }
	 */

	/*
	 * public User userValidation(String userName, String password) { return
	 * clientDAO.userValidation(userName, password); }
	 */

	/**
	 * getClientByApplicationId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#getClientByApplicationId(java.lang.String)
	 * 
	 */
	public Client getClientByApplicationId(String applicationId) throws LookupException {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * findClientByUserName
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findClientByUserName(java.lang.String)
	 * 
	 */
	public Client findClientByUserName(String userName) throws LookupException {

		return this.clientDAO.findClientByUserName(userName);
	}

	/**
	 * findTrakheesIdByUserName
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findTrakheesIdByUserName(java.lang.String)
	 * 
	 */
	public String findTrakheesIdByUserName(String userName) throws LookupException {

		return this.clientDAO.findTrakheesIdByUserName(userName);
	}

	/**
	 * addClientRoleReq
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#addClientRoleReq(ae.pcfc.etks.online.common.domain.ClientRoleReq)
	 * 
	 */
	public void addClientRoleReq(ClientRoleReq clientRoleReq) throws PersistenceException {

		this.clientRoleReqDAO.add(clientRoleReq);

	}

	/**
	 * findClientRolReqByApplicationId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findClientRolReqByApplicationId(java.lang.String)
	 * 
	 */
	public List<ClientRoleReq> findClientRolReqByApplicationId(String applicationId) throws LookupException {

		return this.clientRoleReqDAO.findClientRoleReqByApplicationId(applicationId);
	}

	/**
	 * addClientServiceRole
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#addClientServiceRole(ae.pcfc.etks.online.common.domain.ClientServiceRole)
	 * 
	 */
	public void addClientServiceRole(ClientServiceRole clientServiceRole) throws PersistenceException {

		this.clientServiceRoleDAO.add(clientServiceRole);

	}

	/**
	 * findClientUserByEmail
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findClientUserByEmail(java.lang.String)
	 * 
	 */
	public Client findClientUserByEmail(String email) throws LookupException {

		return this.clientDAO.findClientUserByEmail(email);
	}

	/**
	 * findByTrakheesIds
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findByTrakheesIds(java.util.List)
	 * 
	 */
	public List<Client> findByTrakheesIds(List<TrakheesIdVO> trakheesIdVOs) throws LookupException {

		return this.clientDAO.findByTrakheesIds(trakheesIdVOs);

	}

	/**
	 * findByTrakheesId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findByTrakheesId(java.lang.String)
	 * 
	 */
	public Client findByTrakheesId(String trakheesId) throws LookupException {

		return this.clientDAO.findByTrakheesId(trakheesId);
	}

	/**
	 * findClientRoleReqByClientAndRoleId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findClientRoleReqByClientAndRoleId(java.lang.Long, java.lang.Long)
	 * 
	 */
	public ClientRoleReq findClientRoleReqByClientAndRoleId(Long clientId, Long roleId) throws LookupException {
		return this.clientRoleReqDAO.findClientRoleReqByClientAndRoleId(clientId, roleId);
	}

	/**
	 * findClientRoleReqByTrakheesId
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findClientRoleReqByTrakheesId(java.lang.String)
	 * 
	 */
	public List<ClientRoleReq> findClientRoleReqByTrakheesId(String trakheesId) throws LookupException {
		
		return this.clientRoleReqDAO.findClientRoleReqByTrakheesId(trakheesId);
	}

	/**
	 * findClientServiceRole
	 * 
	 * @see ae.pcfc.etks.online.common.domain.manager.ClientDomainObjectManager#findClientServiceRole(ae.pcfc.etks.online.common.domain.ClientServiceRole)
	 * 
	 */
	public  List<ClientServiceRole> findClientServiceRole(ClientServiceRole clientServiceRole) {
		return this.clientServiceRoleDAO.findClientServiceRole(clientServiceRole);
		
	}
}
